package com.mapper;

import com.domain.RefreshTokenDetail;
import com.domain.User;
import com.domain.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Mapper
public interface UserDao {

    User getUserByPhone(String phone);

    Integer addUser(User user);

    Integer addUserInfo(UserInfo userInfo);

    User getUserByUserId(Long userId);

    UserInfo getUserInfoByUserId(Long userId);

    Integer updateUsers(User user);

    Integer updateUserInfos(UserInfo userInfo);

    List<UserInfo> getUserInfoByUserIds(Set<Long> userIdList);

    Integer pageCountUserInfos(Map<String, Object> params);

    List<UserInfo> pageListUserInfos(Map<String, Object> params);

    User getUserByPhoneOrEmail(@Param("phone") String phone, @Param("email") String email);

    void deleteRefreshToken(@Param("refreshToken") String refreshToken,
                            @Param("userId") Long userId);

    void addRefreshToken(@Param("refreshToken") String refreshToken,
                         @Param("userId") Long userId,
                         @Param("createTime") Date createTime);

    RefreshTokenDetail getRefreshTokenDetail(String refreshToken);

    List<UserInfo> batchGetUserInfoByUserIds(@Param("userIdList") Set<Long> userIdList);

    String getRefreshTokenByUserId(Long userId);
}
